/**
 * @file Intp_Finder.h
 * @brief  Lazy initialization for Interpolation Solver. 
 * @author Linhuo (1066117119@qq.com)
 * @version 1.0
 * @date 2021-06-09
 * 
 * @copyright Copyright (c) 2021  Linhuo
 */
#ifndef _PRO2_INTP_FINDER_H_
#define _PRO2_INTP_FINDER_H_
#include "Intp_Solver.h"
/**
 * @brief An enumeration of Interpolation Function；
 * 		  Linear 　= 　1；
 * 		　Quadratic 　= 　2；
*/
enum Logo_Intper
{
    Linear = 1,
    Quadratic = 2
};

class Intp_Finder
{
private:
    Intp_Solver *p_Intptype;

public:
    Intp_Finder(enum Logo_Intper _method_name, int _dim)
    {
        if (_method_name == Linear && _dim == 1)
            p_Intptype = new Intp_1D_Linear();
        else if (_method_name == Linear && _dim == 2)
            p_Intptype = new Intp_2D_Linear();
        else if (_method_name == Quadratic && _dim == 1)
            p_Intptype = new Intp_1D_Quadratic();
        else if (_method_name == Quadratic && _dim == 2)
            p_Intptype = new Intp_2D_Quadratic();
        else
        {
            std::cout << "Not Found !" << std::endl;
            p_Intptype = NULL;
        };
    };
    void Intp_Reset(enum Logo_Intper _method_name, int _dim)
    {
        if (p_Intptype != NULL)
            delete p_Intptype;
        if (_method_name == Linear && _dim == 1)
            p_Intptype = new Intp_1D_Linear();
        else if (_method_name == Linear && _dim == 2)
            p_Intptype = new Intp_2D_Linear();
        else if (_method_name == Quadratic && _dim == 1)
            p_Intptype = new Intp_1D_Quadratic();
        else if (_method_name == Quadratic && _dim == 2)
            p_Intptype = new Intp_2D_Quadratic();
        else
        {
            std::cout << "Not Found !" << std::endl;
            p_Intptype = NULL;
        };
    };
    ~Intp_Finder() { delete p_Intptype; };
    VectorXd Interpolate(VectorXd _r)
    {
        return p_Intptype->Interpolate(_r);
    };
};
#else
//DO NOTHING
#endif